<div style="position: relative; margin-top: 20px; padding-top: 4px">
    <span class="span-X"><a><i class="fa fa-close"></i></a></span>
    <select class="form-control select2" id="lib-form" required="required" style="margin: 5px 5px" name="content[]">
    </select>
</div>
<input class="btn btn-primary btn-sm" style="margin: 20px 5px;" id="increase_select_add" name="increase_select_add" type="button" value="添加">

@push('scripts')
    <script>
        $('#increase_select_add').on('click', function () {
            node = "<div style=\"position: relative; margin-top: 20px; padding-top: 4px\">\n" +
                "\t<span class=\"span-X\"><a><i class=\"fa fa-close\"></i></a></span>\n" +
                "\t<select class=\"form-control select2\" required=\"required\" style=\"margin: 5px 5px\" name=\"content[]\">\n" +
                "        </select>" +
                "</div>";
            node = $(node).attr('name', "{!! $name !!}" + "[]");
            $(this).before(node);
            $(".select2").select2({
                width: "550px",
                ajax: {
                    dataType: 'json',
                    delay: 250,
                    url: function () {
                        return '{{ route('admin.package.lib.search') }}';
                    },
                    processResults: function (data) {
                        return {
                            results: $.map(data, function(row, key) {
                                return {
                                    id: key,
                                    text: row
                                };
                            })
                        };
                    }
                }
            });
        });
        $(document).on('click', ".span-X", function () {
            $(this).parent().remove();
        });
        $("#lib-form.select2").select2({
            width: "550px",
            ajax: {
                dataType: 'json',
                delay: 250,
                url: function () {
                    return '{{ route('admin.package.lib.search') }}';
                },
                processResults: function (data) {
                    return {
                        results: $.map(data, function(row, key) {
                            return {
                                id: key,
                                text: row
                            };
                        })
                    };
                }
            }
        });
    </script>
@endpush
@push('stylesheets')
    <style>
        .span-X {
            position: absolute;
            z-index: 10;
            border-radius: 10px;
            top: 0px;
            right: -8px;
            padding: 3px;
            line-height: 0;
            background-color: rgba(190,190,190,0.50);
        }
    </style>
@endpush
